package com.tian.controller.api;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.common.CommonResult;
import com.tian.dto.ChargeUserDto;
import com.tian.dto.ChargeUserRegistryReqDto;
import com.tian.service.ChargeUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * {@code @description:} 用户信息接口
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024/1/18 15:03
 * {@code @version:} 1.0
 */
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@RestController
@RequestMapping("/user")
@Api(value = "用户信息接口",tags = "用户信息")
public class ChargeUserController {
    @Resource
    private ChargeUserService chargeUserService;

    @GetMapping("/id")
    @LoginCheckAnnotation
    @ApiOperation(value = "查询我的信息")
    public CommonResult<ChargeUserDto> queryById() {
        return chargeUserService.queryById();
    }

    @PostMapping("/registry")
    @ApiOperation(value = "用户注册")
    public CommonResult<Boolean> registry(@RequestBody ChargeUserRegistryReqDto chargeUserRegistryReqDto) {
        return chargeUserService.register(chargeUserRegistryReqDto);
    }

    @PostMapping("/update/nick/name")
    @ApiOperation(value = "用户昵称修改")
    public CommonResult<Boolean> updateNickName(@RequestBody ChargeUserDto chargeUserDto) {
        return chargeUserService.updateNickNameById(chargeUserDto);
    }
    @PostMapping("/update/avatar/img")
    @ApiOperation(value = "用户头像修改")
    public CommonResult<Boolean> updateAvatarImg(@RequestBody ChargeUserDto chargeUserDto) {
        return chargeUserService.updateAvatarImgById(chargeUserDto);
    }
}
